package beyjava.model;



import java.util.Date;
import java.util.Vector;


/**
 * @author BEYJAVA
 * model class Project
 */
public class Project {
	private Integer projectID;
	private String projectName;
	private String projectDesc;
	private Date projectStartDate;
	Vector<Activity> projectActs = null;	
	/**
	 * @param projectID
	 * @param projectName
	 * @param projectDesc
	 * @param projectStartDate
	 * constructor of project class
	 */
	public Project(Integer projectID, String projectName, String projectDesc,
			Date projectStartDate) {
		super();
		this.projectID = projectID;
		this.projectName = projectName;
		this.projectDesc = projectDesc;
		this.projectStartDate = projectStartDate;
		this.projectActs = new Vector<Activity>();
	}
	/**
	 * @param projectID
	 */
	public void setProjectID(Integer projectID) {
		this.projectID = projectID;
	}
	/**
	 * @return projectID
	 */
	public Integer getProjectID() {
		return projectID;
	}
	/**
	 * @param projectName
	 */
	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}
	/**
	 * @return projectName
	 */
	public String getProjectName() {
		return projectName;
	}
	/**
	 * @param projectDesc
	 */
	public void setProjectDesc(String projectDesc) {
		this.projectDesc = projectDesc;
	}
	/**
	 * @return projectDesc
	 */
	public String getProjectDesc() {
		return projectDesc;
	}
	/**
	 * @param projectStartDate
	 */
	public void setProjectStartDate(Date projectStartDate) {
		this.projectStartDate = projectStartDate;
	}
	/**
	 * @return projectStartDate
	 */
	public Date getProjectStartDate() {
		return projectStartDate;
	}
	/**
	 * @return projectActs
	 */
	public Vector<Activity> getProjectActs() {
		return projectActs;
	}
	/**
	 * @param activities
	 */
	public void setProjectActs(Vector<Activity> activities) {
		this.projectActs = activities;
	}
    /**
     * @param act
     * @return true if activity is added correctly
     */
    public boolean addActivityToProject(Activity act){
    	if(act != null){
    		this.projectActs.add(act);
    		return true;
    	}
    	return false;
    }    
    /**
     * @param act
     * @return success check whether activity is removed correctly or not
     */
    public boolean removeActiviyFromProject(Activity act){
    	boolean success = false; 
    	success = this.getProjectActs().remove(act);
    	return success;
    }
    /**
     * @param newProject
     * @return true if project is updated correctly
     */
    public boolean updateProject(Project newProject){
    	if (newProject != null){
    	     this.setProjectDesc((newProject.getProjectDesc()));
    	     this.setProjectName(newProject.getProjectName());
    	     this.setProjectStartDate(newProject.getProjectStartDate());
    	     return true;
           }
		 return false;
     }
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((projectActs == null) ? 0 : projectActs.hashCode());
		result = prime * result
				+ ((projectDesc == null) ? 0 : projectDesc.hashCode());
		result = prime * result
				+ ((projectID == null) ? 0 : projectID.hashCode());
		result = prime * result
				+ ((projectName == null) ? 0 : projectName.hashCode());
		result = prime
				* result
				+ ((projectStartDate == null) ? 0 : projectStartDate.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Project other = (Project) obj;
		if (projectActs == null) {
			if (other.projectActs != null)
				return false;
		} else if (!projectActs.equals(other.projectActs))
			return false;
		if (projectDesc == null) {
			if (other.projectDesc != null)
				return false;
		} else if (!projectDesc.equals(other.projectDesc))
			return false;
		if (projectID == null) {
			if (other.projectID != null)
				return false;
		} else if (!projectID.equals(other.projectID))
			return false;
		if (projectName == null) {
			if (other.projectName != null)
				return false;
		} else if (!projectName.equals(other.projectName))
			return false;
		if (projectStartDate == null) {
			if (other.projectStartDate != null)
				return false;
		} else if (!projectStartDate.equals(other.projectStartDate))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Project [projectID=" + projectID + ", projectName="
				+ projectName + ", projectDesc=" + projectDesc
				+ ", projectStartDate=" + projectStartDate + ", projectActs="
				+ projectActs + "]";
	}
   
}    
